package com.example.mytest;

import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.IOException;

import android.content.Context;
import android.util.Log;
import android.view.Gravity;
import android.widget.Toast;

public class Comm {
	
	public static void showToast(Context context,String strShowMessage)	{
		Toast toast = Toast.makeText(context, strShowMessage,
				Toast.LENGTH_SHORT);
		toast.setGravity(Gravity.CENTER, 0, 0);
		toast.show();
	}
	
	public static String readInStream(FileInputStream inStream){ 
		  try { 
		   ByteArrayOutputStream outStream = new ByteArrayOutputStream(); 
		   byte[] buffer = new byte[1024]; 
		   int length = -1; 
		   while((length = inStream.read(buffer)) != -1 ){ 
		    outStream.write(buffer, 0, length); 
		   } 
		   outStream.close(); 
		   inStream.close(); 
		   return outStream.toString(); 
		  } catch (IOException e){ 
		   Log.i("FileTest", e.getMessage()); 
		  } 
		  return null; 
		} 
}
